import { combineReducers } from 'redux';

// 添加一个简单的 reducer
const exampleReducer = (state = {}, action) => {
  switch (action.type) {
    case 'EXAMPLE_ACTION':
      return { ...state, exampleData: action.payload };
    default:
      return state;
  }
};

const counterReducer = (state = { count: 0 }, action) => {
  console.log('Counter reducer received action:', action);
  switch (action.type) {
    case 'INCREMENT':
      console.log('Incrementing count');
      return { ...state, count: state.count + 1 };
    default:
      return state;
  }
};

const usersReducer = (state = { users: [] }, action) => {
  console.log('Users reducer received action:', action);
  switch (action.type) {
    case 'SET_USERS':
      return { ...state, users: action.payload };
    default:
      return state;
  }
};

const rootReducer = combineReducers({
  example: exampleReducer,
  counter: counterReducer,
  users: usersReducer,
});

export default rootReducer;
